import login
import download
import os
import time

def get_username_pwd():
    configfile = os.getcwd() + "\\appconfig.txt"
    if os.path.exists(configfile) == False:
        open(configfile , "w")

    fo = open(configfile, "r")
    line = fo.readline()
    line = line.strip()
    return line


def start():
    unamepwd = get_username_pwd();
    arrryup  = unamepwd.split("/")
    if len(arrryup) != 2:
        print("请在appconfig中配置你的用户名和密码，格式为：username/password")
        time.sleep(3)
        return

    usrname  = arrryup[0]
    password = arrryup[1]

    isSuccess = login.doLogin(usrname,password)

    if isSuccess == False:
        return

    print("开始下载") 
    download.doDownLoad()
    print("下载完成")

start()